Skip to content

Support flutter in cross-links and add tests #1680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
May 1, 2018
Merged

Conversation

jcollins-g
Copy link
Contributor

@jcollins-g jcollins-g commented Apr 26, 2018

A batch of changes refining the cross-linking mechanism introduced in #1678. With this, I think it's ready for prime-time use.

  • dartdoc_options _onMissing is refactored to be less repetitive
  • linkToUrl is now a new FileSynth type of dartdoc option (synthetic default, overridable via file). Adds tests for that new type.
  • Add a branch substitution in URL calculations (so we don't have to hardcode "dev")
  • Add a persistent, automatic flutter SDK installation to the grinder that Travis can reuse, refactor existing tests to use it, and write a new test for the new flutter cross-link.
  • Use the new Dart1/Dart2 test runner on Travis as well as AppVeyor, and fix up grinder to not overparallelize on Travis and cause random timeouts.

@googlebot googlebot added the cla: yes Google CLA check succeeded. label Apr 26, 2018
@jcollins-g jcollins-g requested review from devoncarew and pq April 27, 2018 20:40
Copy link
Member

@pq pq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits but substantially LGTM.

@@ -69,7 +69,7 @@ main(List<String> arguments) async {
logInfo("Generating documentation for '${config.topLevelPackageMeta}' into "
"${outputDir.absolute.path}${Platform.pathSeparator}");

Dartdoc dartdoc = await Dartdoc.withDefaultGenerators(config, outputDir);
Dartdoc dartdoc = await Dartdoc.withDefaultGenerators(config);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style question: since you're creatine an instance here, I'd have expected a named factory constructor instead of a static; any reason for that?

EDIT: like withoutGenerators(..)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asynchronous factory (or normal) constructors don't work in Dart. dart-lang/sdk#23115

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, right! I didn't notice the await. Thanks for clarifying. 👍

help: 'Library names to ignore.', splitCommas: true),
new DartdocOptionArgOnly<List<String>>('excludePackages', [],
help: 'Package names to ignore.', splitCommas: true),
// This could be a ArgOnly, but trying to not provide too many ways
// to set the flutter root.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// TODO(jcollins-g): Eliminate special casing for SDK and use config file.
if ((option.root['topLevelPackageMeta'].valueAt(dir) as PackageMeta)
.isSdk ==
true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is awkward formatting.

cc @munificent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rearranged a bit to minimize the impact of dartfmt's choices here.

@@ -80,7 +81,7 @@ int byFeatureOrdering(String a, String b) {
}

final RegExp locationSplitter = new RegExp(r"(package:|[\\/;.])");
final RegExp substituteName = new RegExp(r"%([nv])%");
final RegExp substituteNameVersion = new RegExp(r"%([bnv])%");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe single quotes here and for locationSplitter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jcollins-g
Copy link
Contributor Author

PTAL: the locking around creating the flutter repo was completely wrong and is now fixed.

tool/grind.dart Outdated
RandomAccessFile _updateLock =
new File(pathLib.join(cleanFlutterDir.parent.path, 'lock'))
.openSync(mode: FileMode.WRITE);
_lockFuture = _updateLock.lock();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're using file locking here - is this because you expect multiple dartdoc grind processes to be running simultaneously?

Some of the Future / locking code could be simplified a bit by using a Completer. If the Completer global is null, create one and run the init code. Else, return myCompeter.future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't expect that to happen except accidentally on the command line, which I've done before.

Completers do indeed seem useful and better than this mess. Cleaned this up substantially and reuploaded, PTAL.

@@ -66,7 +66,7 @@ final newLinePartOfRegexp = new RegExp('\npart of ');

final RegExp quotables = new RegExp(r'[ "\r\n\$]');

/// Best used with Future<void>.
/// Best used with Future<Null>.
class MultiFutureTracker<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but there is a pool package (https://pub.dartlang.org/documentation/pool/1.3.4/), which may also do what you want here.

@jcollins-g jcollins-g merged commit 1cf5f34 into master May 1, 2018
@jcollins-g jcollins-g deleted the linking-refinements branch May 1, 2018 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants